package cn.jiyun.controller;


import cn.jiyun.client.AdminClients;
import cn.jiyun.pojo.User;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("admin")
public class AdminController {


    //注入feign
    @Autowired
    private AdminClients adminClients;


    //分页查询
    @GetMapping("findPage")
    public String findPage(@RequestParam(required = true, defaultValue = "1") Integer pageIndex, String name) {

        String page = adminClients.findPage(pageIndex, name);
        return page;
    }

    //删除
    @GetMapping("del")
    public String del(Integer id) {


        return adminClients.del(id);
    }

    //添加
    @PostMapping("add")
    public String add(@RequestBody User user) {

        return adminClients.add(user);
    }


    //回显
    @GetMapping("findById")
    public String findById(Integer id) {

        return adminClients.findById(id);
    }

    //修改
    @PostMapping("edit")
    public String edit(@RequestBody User user) {

        return adminClients.edit(user);
    }
}
